import os

#print(os.getcwd())
#print(os.path.getsize(os.getcwd()))
#print(os.path.getsize("/Users/Yanmin/Documents/python_course"))

def get_size(pathvar):
    lst = os.listdir(pathvar)
    total_size = 0
    for i in lst:
        pathnew = os.path.join(pathvar,i)
        if os.path.isfile(pathnew):
            total_size+= os.path.getsize(pathnew)
        elif os.path.isdir(pathnew):
           total_size+= get_size(pathnew)
    return total_size
# size = get_size('/Users/Yanmin/Documents/书')
print(get_size('/Users/Yanmin/Documents/书'),'Byte')
print("%.2f" %(get_size('/Users/Yanmin/Documents/书') / 1024 / 1024), 'MB')






